Fix fn type mismatch error
authorDavid Davidović <geosoft.corp@gmail.com>
Wed, 24 Dec 2014 02:56:11 +0000 (03:56 +0100)
committerDavid Davidović <geosoft.corp@gmail.com>
Wed, 24 Dec 2014 03:53:13 +0000 (04:53 +0100)
rustc complains that we cannot assign two different fn's to a single
object within an if-else block. I was not able to figure out what causes
this; so deferring the execution of the particular function is a
reasonable fallback. Not very elegant and should be changed to something
with less boilerplate

src/cargo/ops/cargo_rustc/mod.rs

index 115ee044368cdb0ca39be88e5e44f9ab9e32fa8b..348ff2ebfc4f468d046d9a3076f4d0a8bbbc457e 100644 (file)
@@ -201,7 +201,6 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
     // a real job. Packages which are *not* compiled still have their jobs
     // executed, but only if the work is fresh. This is to preserve their
     // artifacts if any exist.
-    let job = if compiled {Job::new} else {Job::noop};
     if !compiled { jobs.ignore(pkg); }
 
     if targets.is_empty() {
@@ -253,7 +252,7 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
                 try!(work.call(desc_tx.clone()));
                 dirty.call(desc_tx)
             });
-            dst.push((job(dirty, fresh), freshness));
+            dst.push((if compiled { Job::new(dirty, fresh) } else { Job::noop(dirty, fresh) }, freshness));
         }
 
         // If this is a custom build command, we need to not only build the
@@ -290,7 +289,7 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
             }
             let (dirty, fresh, freshness) =
                     try!(custom_build::prepare(pkg, target, req, cx));
-            run_custom.push((job(dirty, fresh), freshness));
+            run_custom.push((if compiled { Job::new(dirty, fresh) } else { Job::noop(dirty, fresh) }, freshness));
         }
 
         // If no build scripts were run, no need to compile the build script!
@@ -329,7 +328,7 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
             dirty.call(desc_tx)
         });
         jobs.enqueue(pkg, Stage::BuildCustomBuild, vec![]);
-        jobs.enqueue(pkg, Stage::RunCustomBuild, vec![(job(dirty, fresh),
+        jobs.enqueue(pkg, Stage::RunCustomBuild, vec![(if compiled { Job::new(dirty, fresh) } else { Job::noop(dirty, fresh) },
                                                          freshness)]);
     }